package com.shou.dao;
import com.shou.bean.Organization;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrganizationMapper {

    @Select("SELECT * FROM organization")
    List<Organization> getAllOrganizations();

    @Select("SELECT * FROM organization WHERE id = #{id}")
    Organization getOrganizationById(String id);

    @Insert("INSERT INTO organization (id, name, staff, tel, fax, parentId) " +
            "VALUES (#{id}, #{name}, #{staff}, #{tel}, #{fax}, #{parentId})")
    void insertOrganization(Organization organization);

    @Update("UPDATE organization SET name=#{name}, staff=#{staff}, tel=#{tel}, fax=#{fax}, parentId=#{parentId} WHERE id=#{id}")
    void updateOrganization(Organization organization);

    @Delete("DELETE FROM organization WHERE id=#{id}")
    void deleteOrganization(String id);
}